package com.tsingteng.cosfun.widget.dialog.adapter;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tsingteng.cosfun.R;
import com.tsingteng.cosfun.bean.VideoSectionBean;
import com.tsingteng.cosfun.utils.StringUtils;

import java.util.List;

/**
 * 描述 :
 * 创建人: 肖利.
 * 时间:2018/10/21
 * qq(872179966)
 */

public class VideoSliceTimeAdapter extends BaseQuickAdapter<VideoSectionBean,BaseViewHolder> {
    private  int with = 0;

    public VideoSliceTimeAdapter() {
        super(R.layout.item_video_slice_time_adapter);
    }

    @Override
    protected void convert(BaseViewHolder helper, VideoSectionBean item) {
        List<VideoSectionBean> data = getData();
        TextView mTvLine = helper.getView(R.id.tv_line);
        int time = item.getSectionVideoSpan();
        int all = 0;
        for (int i = 0; i < data.size(); i++) {
            all = all + data.get(i).getSectionVideoSpan();
        }
        int t = 0;
        try {
          t = with /(all/1000);
        }catch (Exception e) {
            e.printStackTrace();
        }
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mTvLine.getLayoutParams();
        layoutParams.width = t * time/1000;
        mTvLine.setLayoutParams(layoutParams);
        if (item.isSelect()) {
            mTvLine.setBackgroundColor(mContext.getResources().getColor(R.color.black));
        }else {
            mTvLine.setBackgroundColor(mContext.getResources().getColor(R.color.gray_ff));
        }



    }

    public void setWith(int with) {
        this.with = with;
    }
}
